﻿using System;
using System.Collections.Generic;
using System.Text;
using IService.Data.IManager;
using System.Data;
using IService.DataDLL;
using IService.Model;

namespace IService.Data.OlbImpl.ManagerImpl
{
    public class ProductsDaManager : IProductsDaManager
    {
        public DataTable GetProductsListAll(Type infoType)
        {
            return DataAccess.SelectAll(infoType);
        }

        public DataTable GetProductsListPagin(Type infoType, PagingEntity pe)
        {
            return DataAccess.SelectPaging(infoType, pe);
        }

        public DataTable GetLatestProductsList(Type infoType, int productsnum)
        {
            string WhereClause = "";
            string Order = "CreateTime desc";
            return DataAccess.SelectTop(infoType, productsnum, WhereClause, Order);
        }

        public Products GetProductsById(Products products)
        {
            products.Select();
            return products;
        }
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="products"></param>
        /// <returns></returns>
        public bool InsertProducts(Products products)
        {
            return DataAccess.Insert(products);
        }

        public bool UpdateProducts(Products products)
        {
            return DataAccess.Update(products);
        }

        public bool DeleteProducts(Products products)
        {
            return DataAccess.Delete(products);
        }

        public bool DeleteProductsByIds(Type infoType, string Ids)
        {
            string WhereClause = "Id in(" + Ids + ")";
            return DataAccess.Delete(infoType, WhereClause);
        }
    }
}
